<?php

/*
**	Search
**	Displays search results.
**
**	- 'Search' page shall display 25 posts at a time.
*/



$data['applicationTitle'] = $this->lang->line('ligature_title');;
$data['pageTitle'] = $this->lang->line('ligature_search_title');
$data['pageId'] = 'search';

$data['message'] = $this->session->flashdata('message');

$postCount  = $this->Ligature_Post_model->findCount($searchTerms);
$perPage    = 25;
$lastPage   = floor($postCount / $perPage) + 1;

if (!isset($currentPage) || is_null($currentPage) || !is_numeric($currentPage)) {
    // show first page
    $currentPage = 1;
} elseif (($currentPage - 1) * $perPage > $postCount) {
    // current page beyond number of posts, show last page
    $currentPage = $lastPage;
}

$data['searchTerms'] = $searchTerms;
$data['allPosts'] = $this->Ligature_Post_model->findPost($searchTerms);
$data['hasEarlierPosts'] = ($currentPage < $lastPage);
$data['hasLaterPosts'] = ($currentPage > 1);
$data['currentPage'] = $currentPage;
$data['recentComments'] = $this->Ligature_Comment_model->listComment();

$this->load->view($this->config->item('theme', 'ligature') . '/header', $data);
$this->load->view($this->config->item('theme', 'ligature') . '/home', $data);
$this->load->view($this->config->item('theme', 'ligature') . '/footer', $data);


/* clickframes::version=2804949453::clickframes */
?>